﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.BlogCore.Controls.Button
 * 唯一标识：a71af05a-c00f-471d-9704-e5dd34bb0f7c
 * 文件名：ButtonGroup
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/6/25 15:34:10
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.BlogCore;

/// <summary>
/// 按钮组
/// </summary>
public sealed class ButtonGroup : ContainerControlBase<Button>
{
    /// <summary>
    /// 构造函数
    /// </summary>
    internal ButtonGroup()
    {
    }

    public override string Title { get; set; }
    public override List<Button> Children { get; internal set; }
    public override string Id { get; set; }

    public override string ConverToHtml()
    {
        StringBuilder sb = new StringBuilder();

        sb.AppendLine($"<el-button-group>");
        foreach (var item in Children)
        {
            sb.AppendLine(item.ConverToHtml());
        }
        sb.AppendLine($"</el-button-group>");

        return sb.ToString();
    }
}

public static partial class App
{
    /// <summary>
    /// 创建按钮组
    /// </summary>
    /// <param name="buttons"></param>
    /// <returns></returns>
    public static ButtonGroup CreateButtonGroup(Action<List<Button>> buttons)
    {
        ButtonGroup bg = new ButtonGroup();
        bg.Children = new List<Button>();

        buttons.Invoke(bg.Children);

        return bg;
    }
}